﻿@model ShipmentModel
<div>
    <div class="form-horizontal">
        <div class="form-body">
            <div class="form-group">
                <admin-label asp-for="OrderId"/>
                <div class="col-md-9 col-sm-9">
                    <label class="control-label">
                        <a href="@Url.Action("Edit", "Order", new { Id = Model.OrderId, area = Constants.AreaAdmin })">@Model.OrderNumber - @Loc["Admin.Common.View"]</a>
                    </label>
                </div>
            </div>
            <div class="form-group">
                <admin-label asp-for="TrackingNumber"/>
                <div class="col-md-6">
                    <div class="input-group">
                        <div class="input-group-control">
                            <admin-input asp-for="TrackingNumber"/>
                        </div>
                        <div class="input-group-append">
                            <input type="submit" name="settrackingnumber" asp-action="SetTrackingNumber" value="@Loc["Admin.Orders.Shipments.TrackingNumber.Button"]" class="btn default"/>
                            @if (!string.IsNullOrEmpty(Model.TrackingNumberUrl))
                            {
                                <a href="@Model.TrackingNumberUrl" target="_blank" class="tracking-url">@Loc["Admin.Orders.Shipments.TrackingNumber.ViewOnline"]</a>
                            }
                        </div>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <admin-label asp-for="AdminComment"/>
                <div class="col-md-6">
                    <div class="input-group">
                        <div class="input-group-control">
                            <admin-input asp-for="AdminComment"/>
                        </div>
                        <div class="input-group-append">
                            <input type="submit" name="setadmincomment" asp-action="SetShipmentAdminComment" value="@Loc["Admin.Orders.Shipments.AdminComment.Button"]" class="btn default"/>
                        </div>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <admin-label asp-for="TotalWeight"/>
                <div class="col-md-9 col-sm-9">
                    <label class="control-label">@Model.TotalWeight</label>
                </div>
            </div>
            <div class="form-group">
                <admin-label asp-for="ShippedDate"/>
                <div class="col-md-9 col-sm-9">
                    <span id="lblShippedDate">
                        @if (Model.ShippedDate.HasValue)
                        {
                            @Model.ShippedDate.Value.ToString(CultureInfo.InvariantCulture)
                        }
                        else
                        {
                            <text>@Loc["Admin.Orders.Shipments.ShippedDate.NotYet"]</text>
                        }
                    </span>
                    @if (Model.CanShip)
                    {
                        <input type="submit" name="setasshipped" asp-action="SetAsShipped" value="@Loc["Admin.Orders.Shipments.ShippedDate.Button"]" id="setasshipped" class="btn default"/>
                    }
                    @if (Model.ShippedDateUtc.HasValue)
                    {
                        <div id="divShippedDate" style="display: inline-block;"><admin-input asp-for="ShippedDate"/> &nbsp;@Loc["Admin.Orders.Shipments.ShippedDate.Enter"]</div>
                        <button type="submit" id="btnEditShippedDate" onclick=" toggleShippedDate(true);return false; " class="k-button"><span class="k-icon k-i-edit"></span>&nbsp;@Loc["Admin.Common.Edit"]</button>
                        <button type="submit" id="btnSaveShippedDate" asp-action="EditShippedDate" name="saveshippeddate" onclick=" return confirm('@Loc["Admin.Common.AreYouSure"]'); " class="k-button"><span class="k-icon k-i-save"></span>&nbsp;@Loc["Admin.Common.Save"]</button>
                        <button type="submit" id="btnCancelShippedDate" onclick=" toggleShippedDate(false);return false; " class="k-button"><span class="k-icon k-i-cancel"></span>&nbsp;@Loc["Admin.Common.Cancel"]</button>
                    }
                </div>
            </div>
            <div class="form-group">
                <admin-label asp-for="DeliveryDate"/>
                <div class="col-md-9 col-sm-9">
                    <span id="lblDeliveryDate">
                        @if (Model.DeliveryDate.HasValue)
                        {
                            @Model.DeliveryDate.Value.ToString(CultureInfo.InvariantCulture)
                        }
                        else
                        {
                            <text>@Loc["Admin.Orders.Shipments.DeliveryDate.NotYet"]</text>
                        }
                    </span>
                    @if (Model.CanDeliver)
                    {
                        <input type="submit" name="setasdelivered" asp-action="SetAsDelivered" value="@Loc["Admin.Orders.Shipments.DeliveryDate.Button"]" id="setasdelivered" class="btn default"/>
                    }
                    @if (Model.DeliveryDateUtc.HasValue)
                    {
                        <div id="divDeliveryDate" style="display: inline-block;"><admin-input asp-for="DeliveryDate"/> &nbsp;@Loc["Admin.Orders.Shipments.DeliveryDate.Enter"]</div>
                        <button type="submit" id="btnEditDeliveryDate" onclick=" toggleDeliveryDate(true);return false; " class="k-button"><span class="k-icon k-i-edit"></span>&nbsp;@Loc["Admin.Common.Edit"]</button>
                        <button type="submit" id="btnSaveDeliveryDate" asp-action="EditDeliveryDate" name="savedeliverydate" onclick=" return confirm('@Loc["Admin.Common.AreYouSure"]'); " class="k-button"><span class="k-icon k-i-save"></span>&nbsp;@Loc["Admin.Common.Save"]</button>
                        <button type="submit" id="btnCancelDeliveryDate" onclick=" toggleDeliveryDate(false);return false; " class="k-button"><span class="k-icon k-i-cancel"></span>&nbsp;@Loc["Admin.Common.Cancel"]</button>
                    }
                </div>
            </div>
        </div>
    </div>
</div>

<table class="table table-striped table-hover">
    <tr>
        <td>
            <strong>@Loc["Admin.Orders.Shipments.Products"]</strong>
        </td>
    </tr>
    <tr>
        <td>
            <table class="table table-bordered table-striped table-hover">
                <thead>
                <tr>
                    <th>
                        @Loc["Admin.Orders.Shipments.Products.ProductName"]
                    </th>
                    <th>
                        @Loc["Admin.Orders.Shipments.Products.SKU"]
                    </th>
                    <th>
                        @Loc["Admin.Orders.Shipments.Products.Warehouse"]
                    </th>
                    <th>
                        @Loc["Admin.Orders.Shipments.Products.ItemWeight"]
                    </th>
                    <th>
                        @Loc["Admin.Orders.Shipments.Products.ItemDimensions"]
                    </th>
                    <th>
                        @Loc["Admin.Orders.Shipments.Products.QtyShipped"]
                    </th>
                </tr>
                </thead>
                <tbody>
                @foreach (var item in Model.Items)
                {
                    <tr>
                        <td>
                            <div style="padding-left: 10px; padding-right: 10px;">
                                <em>
                                    <a href="@Url.Action("Edit", "Product", new { id = item.ProductId, area = Constants.AreaAdmin })">@item.ProductName</a>
                                </em>
                                @if (!string.IsNullOrEmpty(item.AttributeInfo))
                                {
                                    <p>
                                        @Html.Raw(item.AttributeInfo)
                                    </p>
                                }
                                @if (!string.IsNullOrEmpty(item.RentalInfo))
                                {
                                    <p>
                                        @Html.Raw(item.RentalInfo)
                                    </p>
                                }
                            </div>
                        </td>
                        <td>
                            <div style="padding-left: 10px; padding-right: 10px;">
                                @item.Sku
                            </div>
                        </td>
                        <td>
                            <div style="padding-left: 10px; padding-right: 10px;">
                                @item.ShippedFromWarehouse
                            </div>
                        </td>
                        <td>
                            @item.ItemWeight
                        </td>
                        <td>
                            @item.ItemDimensions
                        </td>
                        <td>
                            @item.QuantityInThisShipment
                        </td>
                    </tr>
                }
                </tbody>
            </table>
        </td>
    </tr>
</table>

@if (Model.ShipmentStatusEvents.Count > 0)
{
    <div class="form-horizontal">
        <div class="note note-info">
            @Loc["Admin.Orders.Shipments.ShipmentStatusEvents"]
        </div>
        <div class="form-body">
            <div class="form-group">
                <table class="table table-bordered table-striped table-hover">
                    <thead>
                    <tr>
                        <th align="center">
                            @Loc["Admin.Orders.Shipments.ShipmentStatusEvents.Event"]
                        </th>
                        <th align="center">
                            @Loc["Admin.Orders.Shipments.ShipmentStatusEvents.Location"]
                        </th>
                        <th align="center">
                            @Loc["Admin.Orders.Shipments.ShipmentStatusEvents.Country"]
                        </th>
                        <th align="center">
                            @Loc["Admin.Orders.Shipments.ShipmentStatusEvents.Date"]
                        </th>
                    </tr>
                    </thead>
                    <tbody>
                    @foreach (var item in Model.ShipmentStatusEvents)
                    {
                        <tr>
                            <td style="width:40%;">
                                <div style="padding-left: 10px; padding-right: 10px;">
                                    @item.EventName
                                </div>
                            </td>
                            <td style="width:20%;">
                                <div style="padding-left: 10px; padding-right: 10px;">
                                    @item.Location
                                </div>
                            </td>
                            <td style="width:20%;">
                                <div style="padding-left: 10px; padding-right: 10px;">
                                    @item.Country
                                </div>
                            </td>
                            <td style="width:20%;">
                                <div style="padding-left: 10px; padding-right: 10px;">
                                    @if (item.Date.HasValue)
                                    {
                                        @item.Date.Value.ToString("D")
                                    }
                                </div>
                            </td>
                        </tr>
                    }
                    </tbody>
                </table>
            </div>
        </div>
    </div>
}